<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <script src="../res/js/jquery-3.4.1.min.js"></script>
    <script src="../res/layui/layui.js" charset="utf-8"></script>
    <script src="../res/js/Tools.js"></script>
    <link rel="stylesheet" href="../res/layui/css/layui.css" media="all">
    <link href="../res/echarts/eleTree.css" rel="stylesheet"/>
    <script src="../res/echarts/eleTree.js"></script>
    <script src="../res/js/login_common.js" charset="utf-8"></script>
    <style type="text/css">
        body {
            padding: 10px;
        }
    </style>

</head>
<body>
<form class="layui-form" action="">
    <input type="hidden" id="userId" name="userId">
    <div class="layui-form-item">

        <div class="layui-form-item">

            <div class="layui-inline">
                <label class="layui-form-label">原密码：</label>
                <div class="layui-input-inline">
                    <input type="password" name="userPassword" id="userPassword" lay-verify="required" placeholder="请输入"
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">

            <div class="layui-inline">
                <label class="layui-form-label">新密码：</label>
                <div class="layui-input-inline">
                    <input type="password" name="newUserPassword" id="newUserPassword" lay-verify="required"
                           placeholder="请输入"
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">确认密码：</label>
                <div class="layui-input-inline">
                    <input type="password" name="newUserPasswords" id="newUserPasswords" lay-verify="required"
                           placeholder="请输入"
                           autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1" id="sub">立即提交</button>
            </div>
        </div>
</form>
<script type="text/javascript">

</script>
<script>

    layui.use(['form', 'layedit', 'laydate', 'layer'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        $("#demo1-getValue").on("click", function () {
            var selectArr = clients.getValue();
            console.info(selectArr);
        })

        //监听提交
        form.on('submit(demo1)', function (data) {
            console.info($("#userPassword").val()+"==="+window.loginObj.manager.userPassword);
            if($("#userPassword").val()!=window.loginObj.manager.userPassword){

                layer.alert('原密码输入错误', {
                    icon: 2,
                    skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则，去这里查阅
                })


            }else if($("#newUserPassword").val()!=$("#newUserPasswords").val()){
                layer.alert('俩次密码不一致', {
                    icon: 2,
                    skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则，去这里查阅
                })
            }else{
                var url = "../userAction/updatePwd";

                $.post(url, data.field, function (obj) {
                    if (obj.num == 1) {
                        window.loginObj.manager.userPassword=$("#newUserPassword").val();
                        window.parent.location.reload();//刷新父页面
                        /*var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);*/
                    }
                }, "json")
            }


            return false;
        });

        $("#userId").val(window.loginObj.manager.userId);

        //表单取值
        layui.$('#LAY-component-form-getval').on('click', function () {
            var data = form.val('example');
            alert(JSON.stringify(data));
        });


        form.render();
    });
</script>
<!--
<script type="text/javascript">
    /**
     * 修改日历格式
     * @param dates
     * @returns {string}
     */
    function setDate(dates) {
        var date = new Date(dates);
        var month = date.getMonth() + 1;
        var day = date.getDate();
        var sdate = date.getFullYear() + "-"
        if (month < 10) {
            sdate += "0" + month + "-";
        } else {
            sdate += month + "-";
        }
        if (day < 10) {
            sdate += "0" + day;
        } else {
            sdate += day;
        }
        return sdate;
    }
</script>-->
</body>
</html>